const redis = require('../redis/init.js');
const initArticles = require('../redis/articlesinit.js')
const redisCacheArticlesMiddleWare = async (req, res, next) => {
  const articlesListExists = await redis.exists('articlesList');
  if(articlesListExists){
    next()
  }
  else{
    await initArticles(redis)
    next()
  }

};

module.exports = redisCacheArticlesMiddleWare;
